/*
package com.sports.demo;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

*/
/**
 * @author shirengang
 *//*

public class MpGenerator {

  public static void main(String[] args) throws InterruptedException {

    //用来获取Mybatis-Plus.properties文件的配置信息
    //final ResourceBundle rb = ResourceBundle.getBundle("mybatisplus");
    final ResourceBundle rb = ResourceBundle.getBundle("application");
    String name;
    // 代码生成器
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir("D:/workspace/sports/src/main/java");  //修改成自己的项目路径一直到java
    gc.setFileOverride(true);//覆盖已有文件
    gc.setOpen(false);
    gc.setBaseResultMap(true);
    gc.setBaseColumnList(true);
    gc.setAuthor("SRG");
    gc.setMapperName("%sMapper");
    gc.setXmlName("%sMapper.xml");
    gc.setServiceName("%sService");
    gc.setServiceImplName("%sServiceImpl");
    gc.setControllerName("%sController");
    gc.setDateType(DateType.ONLY_DATE);
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setUrl("jdbc:mysql://101.43.2.227:3306/sports?useUnicode=true&characterEncoding=utf8&useSSL=false");
    dsc.setDriverName("com.mysql.cj.jdbc.Driver");
    dsc.setUsername("sports");
    dsc.setPassword("srkbXRMYjAp4EJFx");
    dsc.setTypeConvert(new MySqlTypeConvertCustom());
    mpg.setDataSource(dsc);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setParent("com.sports.demo");
    //pc.setController("controller");
    pc.setService("service");
    pc.setServiceImpl("service.impl");
    pc.setEntity("model");
    pc.setMapper("dao");
    mpg.setPackageInfo(pc);

    // 自定义配置
    InjectionConfig cfg = new InjectionConfig() {
      @Override
      public void initMap() {
        // to do nothing
      }
    };
    // 如果模板引擎是 freemarker
    String templatePath = "/templates/mapper.xml.ftl";
    // 如果模板 引擎是 velocity
    //String templatePath = "/templates/mapper.xml.vm";
    List<FileOutConfig> focList = new ArrayList<>();
    focList.add(new FileOutConfig(templatePath) {
      @Override
      public String outputFile(TableInfo tableInfo) {
        // 自定义输入文件名称
        return "D:/workspace/sports/src/main/resources" + "/mapper/" + tableInfo.getEntityName() + StringPool.DOT_XML;
      }
    });
    cfg.setFileOutConfigList(focList);
    mpg.setCfg(cfg);
    mpg.setTemplate(new TemplateConfig().setXml(null));

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    strategy.setNaming(NamingStrategy.underline_to_camel);
    strategy.setColumnNaming(NamingStrategy.underline_to_camel);
    strategy.setEntityLombokModel(true);

    //建立不包含哪些表
    //strategy.setExclude(new String[]{rb.getString("tableName")});

    //建立包含哪些表空 为所有表
    strategy.setInclude();
    mpg.setStrategy(strategy);
    mpg.setTemplateEngine(new FreemarkerTemplateEngine());
    mpg.execute();
  }




}
*/
/**
 * 自定义类型转换
 *//*

class MySqlTypeConvertCustom extends MySqlTypeConvert implements ITypeConvert{
  @Override
  public IColumnType processTypeConvert(GlobalConfig globalConfig, String fieldType) {
    String t = fieldType.toLowerCase();
    if (t.contains("tinyint(1)")) {
      return DbColumnType.INTEGER;
    }
    return super.processTypeConvert(globalConfig, fieldType);
  }
}
*/
